
Point = function(x,y, color){
    this.x = x;
    this.y = y;
    this.color = color;
    this.size = 2;
    //this.collision = false;

    this.draw = function(context){
        context.save();
        context.beginPath();
        context.arc(this.x, this.y, this.size, 0, 2 * Math.PI, false);
        context.fillStyle = this.color;
        context.fill();
        context.lineWidth = 1;
        context.strokeStyle = this.color;
        context.stroke();
        
        context.fillStyle = this.color;
        context.fillRect(this.x, this.y, this.size, this.size);
        context.fill();
        context.restore();
    };
    this.dot = function(point){
        return this.x*point.x + this.y*point.y;
    };
    this.add = function(point){
        var toReturn = new Point();
        toReturn.x = this.x+point.x;
        toReturn.y = this.y+point.y;
        return toReturn;
    };
    this.subtract = function(point){
        var toReturn = new Point();
        toReturn.x = this.x-point.x;
        toReturn.y = this.y-point.y;
        return toReturn;
    };
    this.rotate = function(theta, referencePoint){
        //p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox
        //p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy
        var toReturn = new Point();
        toReturn.x = Math.cos(theta)*(this.x-referencePoint.x) - Math.sin(theta)*(this.y-referencePoint.y) + referencePoint.x
        toReturn.y = Math.sin(theta)*(this.x-referencePoint.x) + Math.cos(theta)*(this.y-referencePoint.y) + referencePoint.y;
        return toReturn;
    };
}